package LinkedList;



public class Main {
    //不带傀儡结点的链表
    public static Node creatList() {
        Node a = new Node(1);
        Node b = new Node(2);
        Node c = new Node(3);
        Node d = new Node(4);
//        Node e = new Node(3);


        a.next = b;
        b.next = c;
        c.next = d;
        d.next = null;
//        e.next = null;

        return a;
    }



    public static void main(String[] args) {
        Node head = creatList();//创建不带傀儡结点的链表
        simpleOperation(head);//普通链表简单的遍历操作

//        Node cur = head;
//        while (cur != null) {
//            System.out.print(" "+cur.val);
//            cur = cur.next;
//        }

    }
    public static void simpleOperation(Node head) {
        Operation_01 operation = new Operation_01();
//        operation.printFor(head);//for循环打印链表
//        operation.printWhile(head);//while循环打印链表
//        operation.findEnd(head);//寻找链表最后一个元素
        operation.findEndTwo(head);//寻找链表倒数第二个元素
//        operation.findN(head, 2);//寻找链表第n个元素
//        operation.findEndN(head, 2);//寻找链表倒数第N个元素
        boolean b = operation.contains(head, 3);//判断链表是否包含某个元素
//        if (b == true) {
//            System.out.println("找到了");
//        } else {
//            System.out.println("没找到");
//        }
    }


}

